Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom function to read MultiNest output data #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

larrybradley
Copy link
Contributor

@larrybradley larrybradley commented Dec 18, 2023

By default, Fortran drops the "E" symbol for 3-digit exponent output (e.g., '0.148232-104'). This impacts the output files currently being written by (Py)MultiNest.

This PR adds a custom function to read MultiNest output data, including cases of 3-digit exponents. For such cases, the reader inserts the "E" symbol into the number string so that the number can be converted to a float.

ref: JohannesBuchner/PyMultiNest#212

@ACCarnall
Copy link
Owner

Hi Larry,

Has this actually been causing problems for you? My understanding is that this basically only ever comes up when there's a bug in the fitting somewhere which is causing the likelihood function to return a nan. In those cases it's not a super helpful error message that gets generated I'll admit, but potentially it's better than the code just proceeding anyway. The solution is probably to implement this, but also probably to figure out what values coming back from MultiNest mean the likelihood function returned nan and raise an exception in that case.

Cheers,
Adam

@larrybradley
Copy link
Contributor Author

@ACCarnall This isn't really causing an issue for me. I did have had it occur on a few occasions when I was first using Bagpipes, but I don't recall the specifics (perhaps max redshift set too low, or NaN/inf in error arrays?). Clearly something had to go wrong to get triple-digit exponents. In any case this PR prevents the cryptic error message. I'm not sure if the code would later fail downstream of this or just produce garbage results. Unfortunately, I don't have a reproducible test case. It might be a good idea to raise an exception with a meaningful error message for triple-digit exponents.

@larrybradley
Copy link
Contributor Author

larrybradley commented Feb 27, 2024

Indeed, I can reproduce the error if I try to fit a high-z galaxy (z > 10) with a low max_redshift in config.py:

   samples2d = np.loadtxt(self.fname + "post_equal_weights.dat")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   arr = _load_from_filelike(
          ^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string '0.233419537011120611-312' to float64 at row 0, column 8.

@HinLeung622
Copy link
Contributor

I recall that this specific issue only occurs when something is terribly wrong, for example the incorrection max_redshift setting mentioned above, and when I replace the likelihood function into something custom but incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants